package cn.itsource.exam.controller;

import cn.itsource.exam.domain.Exam;
import cn.itsource.exam.domain.StudentExam;
import cn.itsource.exam.query.ExamResultQuery;
import cn.itsource.exam.service.ExamResultService;
import cn.itsource.exam.util.AjaxResult;
import cn.itsource.exam.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/examResult")
public class ExamResultController {
    @Autowired
    private ExamResultService examResultService;

    @PostMapping("/list")
    public PageList<Exam> selectExamList(@RequestBody ExamResultQuery map){
        PageList<Exam> list = examResultService.selectExamResultList(map);
        return list;
    }
    @PutMapping("/exam")
    public AjaxResult updateExamList(@RequestBody StudentExam map){
        try {

            examResultService.updateExam(map);
        }catch (Exception e){
            e.printStackTrace();
        }
        return AjaxResult.success();
    }

    @PostMapping("confirm/{id}")
    public AjaxResult confirm(@PathVariable("id") Long id){
        try {
            examResultService.confirmExam(id);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error();
        }
        return AjaxResult.success();
    }

}
